#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
const int maxm=1e6+10;
int h,top1,ll[maxn],rr[maxn],t,n,m,l,v,d[maxn],p[maxn],nxt[maxm],k,num1,num2,s[maxm],ans,c[maxm],cnt,top,L[maxn],R[maxn];
long double T,x,u[maxn],a[maxn];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--){
        ans=0;cnt=0;top=0;
        memset(c,0,sizeof(c));
        memset(nxt,0,sizeof(nxt));
        memset(s,0,sizeof(s));
        memset(ll,0,sizeof(ll));
        memset(rr,0,sizeof(rr));
        top1=0;
        cin>>n>>m>>l>>v;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>u[i]>>a[i];
        }
        for(int i=1;i<=m;i++){
            cin>>p[i];
        }
        sort(p+1,p+m+1);
        for(int i=2;i<=m;i++){
            nxt[p[i-1]]=p[i];
        }
        nxt[p[m]]=l+1;
        for(int i=1;i<=n;i++){
            if(a[i]<0){
                if(u[i]<=v)continue;
                T=(u[i]-(long double)(v))/(-1.000000*a[i]);
                x=u[i]*T+a[i]*T*T/2.000000+1.000000*(d[i]);
                if(x==(int)(x))x-=1;
                k=(int)(x);
                k=min(k,l);
                num2=lower_bound(p+1,p+m+1,k)-p;
                while(p[num2]>k)num2--;
                num1=upper_bound(p+1,p+m+1,d[i])-p;
                while(p[num1-1]==d[i])num1--;
                if(num1<1||num1>m||num2<1||num2>m||num1>num2)continue;
                s[p[num1]]++;s[nxt[p[num2]]]--;
                L[++top]=num1;R[top]=num2;
                ans++;
            }
            else if(a[i]>0){
                if(u[i]>v){
                    num1=upper_bound(p+1,p+m+1,d[i])-p;
                    while(p[num1-1]==d[i])num1--;
                    num2=m;
                    if(num1<1||num1>m||num2<1||num2>m||num1>num2)continue;
                    s[p[num1]]++;s[nxt[p[num2]]]--;
                    L[++top]=num1;R[top]=num2;
                    ans++;
                }
                else{
                    T=(v-u[i])/a[i];
                    x=u[i]*T+a[i]*T*T/2.000000+(long double)(d[i]);
                    k=(int)(x+1);
                    num1=upper_bound(p+1,p+m+1,k)-p;
                    while(p[num1-1]==k)num1--;
                    num2=m;
                    if(num1<1||num1>m||num2<1||num2>m||num1>num2)continue;
                    s[p[num1]]++;s[nxt[p[num2]]]--;
                    L[++top]=num1;R[top]=num2;
                    ans++;
                }
            }
            else if(a[i]==0){
                if(u[i]<=v)continue;
                num1=upper_bound(p+1,p+m+1,d[i])-p;
                while(p[num1-1]==d[i])num1--;
                num2=m;
                //if(i==2)cout<<num1<<" "<<num2<<endl;
                if(num1<1||num1>m||num2<1||num2>m||num1>num2)continue;
                s[p[num1]]++;s[nxt[p[num2]]]--;
                L[++top]=num1;R[top]=num2;
                ans++;
            }
        }

        cout<<ans<<" ";
        ans=0;
        for(int i=1;i<=m;i++){
            c[i]=c[i-1]+s[p[i]];
        }
        if(top==0){
            cout<<n<<endl;
            continue;
        }
        ll[1]=L[1],rr[1]=R[1];ans=1;
        top1=1;
        for(int i=2;i<=top;i++){
            h=0;
            for(int j=1;j<=top1;j++){
                if(ll[j]<=R[i]&&L[i]<=rr[j]){
                    ll[j]=max(ll[j],L[i]);
                    rr[j]=min(rr[j],R[i]);
                    h=1;
                }
            }
            if(h==0){
                ll[++top1]=L[i];rr[top1]=R[i];
                ans++;
            }
        }
        cout<<n-ans<<endl;
    }
    return 0;
}
